<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script type="text/javascript">

    /**
     * 构造函数里面可以通过 this 关键字定义属性和方法
     * @constructor
     */
    function People(n, a) {
        /*this.属性名 = 属性值*/
        this.username = n;
        this.age = a;


        /*this.方法名 = 函数表达式*/
        this.run = function () {
            console.log(this.username, '在奔跑');
        }
    }

    var p1 = new People('liyang', 12);
    console.log(p1);
    console.log(p1.username);
    p1.run();


    console.log('新的对象');
    var p2 = new People('mark', 23);
    console.log(p2);
    console.log(p2.username);
    p2.run();


</script>

</html>
